package com.crocodileQ.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.crocodileQ.common.R;
import com.crocodileQ.constants.SystemConstants;
import com.crocodileQ.domain.VO.LinkVO;
import com.crocodileQ.domain.entity.Link;
import com.crocodileQ.mapper.LinkMapper;
import com.crocodileQ.service.LinkService;
import com.crocodileQ.utils.BeanCopyUtil;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (Link)表服务实现类
 *
 * @author 鳄鱼杆
 * @since 2024-01-01 19:39:35
 */
@Service("linkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {

    /**
     * 获取全部的友链
     * @return
     */
    public R<List<LinkVO>> getAllLink() {

        //查询所有审核通过的
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Link::getStatus, SystemConstants.LINK_STATUS_NORMAL);

        List<Link> list = list(queryWrapper);
        //转成VO
        List<LinkVO> linkVOS = BeanCopyUtil.copyBeanList(list, LinkVO.class);

        return R.success(linkVOS);
    }
}

